<template>
  <div class="app-container">
    <div class="search-group">
      <div class="input-wrap">
        <div class="label">餐厅名称:</div>
        <div class="input-item">
          <j-input :maxLength="30" clearable v-model="queryParam.restaurantName" placeholder="请输入餐厅名称" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">设备组名称:</div>
        <div class="input-item">
          <j-input :maxLength="30" clearable v-model="queryParam.deviceName" placeholder="请输入设备组名称" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">监测仪MN码:</div>
        <div class="input-item">
          <j-input :maxLength="30" clearable v-model="queryParam.deviceMonitorMn" placeholder="请输入监测仪MN码" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">核查时间:</div>
        <div class="time-item">
          <start-end-time
            :times="times"
            :showTime="{ format: 'HH:mm:ss' }"
            format="YYYY-MM-DD HH:mm:ss"
            @timeChange="timeChange"
            :resetTime="resetTime"
          ></start-end-time>
        </div>
      </div>

      <div class="btn-wrap">
        <a-button
          class="searchBtn"
          @click="searchQuery(queryParam.createTime_begin, queryParam.createTime_end)"
          type="primary"
        >
          搜索
        </a-button>
        <a-button class="resetBtn" @click="searchReset()" type="primary">重置</a-button>
      </div>
    </div>

    <div class="flex table-wrap">
      <a-table
        rowKey="id"
        class="tableList f1"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        @change="handleTableChange"
      >
        <template v-slot:action="records">
          <span class="operation deatil-color" @click="detailHandle(records)">详情</span>
        </template>
      </a-table>
    </div>
    <detail-modal ref="detailModal"></detail-modal>
  </div>
</template>
<script>
import detailModal from './modules/detailModal'
import JInput from '@/components/jeecg/JInput'
import startEndTime from '@/components/startEndTime'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { mapState } from 'vuex'
export default {
  name: 'app-container',
  components: { startEndTime, detailModal, JInput },
  mixins: [JeecgListMixin],
  computed: {
    ...mapState({
      isAgencyId: (state) => state.user.isAgencyId,
    }),
  },
  watch: {
    isAgencyId(v) {
      this.queryParam.unitId = v.id ? v.id : ''
      this.searchQuery()
    },
  },
  data() {
    return {
      url: {
        list: '/police/work_order_record/page?status=2&type=1',
        // status 0 待处理 1 已处理 2 已回执
        // type 1 告警 2 离线
        tree: true,
      },
      isorter: {
        column: 'handleTime',
        order: 'desc',
      },
      informationList: [],
      columns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '所属餐厅',
          dataIndex: 'restaurantName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '设备组名称',
          dataIndex: 'deviceName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '监测仪MN码',
          dataIndex: 'deviceMonitorMn',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '餐厅负责人',
          dataIndex: 'restaurantChargeName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '负责人联系电话',
          dataIndex: 'restaurantChargePhone',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '监管单位',
          dataIndex: 'unitName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '核查城管',
          dataIndex: 'policeUserName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '核查时间',
          dataIndex: 'handleTime',
          width: 200,
          ellipsis: true,
          align: 'center',
        },
        {
          title: '操作',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      detailFlag: false,
      records: {},
    }
  },
  mounted() {},
  methods: {
    timeChange(v, index) {
      if (index == 1) {
        this.queryParam.createTime_begin = this.$moment(v).valueOf()
      } else {
        this.queryParam.createTime_end = this.$moment(v).valueOf()
      }
      if (v == null) {
        this.queryParam.createTime_begin = null
        this.queryParam.createTime_end = null
      }
    },
    detailHandle(records) {
      this.$refs.detailModal.show(records, 1)
    },
  },
}
</script>
